package cz.proks.easyhelpdesk.gwt.event;

import com.google.gwt.event.shared.EventHandler;
import com.google.gwt.event.shared.GwtEvent;

import cz.proks.easyhelpdesk.api.model.Ticket;

public class TicketSaveEvent extends GwtEvent<TicketSaveEvent.Handler> {
    public final static Type<TicketSaveEvent.Handler> TYPE = new Type<TicketSaveEvent.Handler>();
    
    public static interface Handler extends EventHandler {
        void onTicketSave(TicketSaveEvent event);
    }
    
    private final Ticket ticket;

    public TicketSaveEvent(Ticket ticket) {    
        this.ticket = ticket;
    }
    
    public Ticket getTicket() {
        return ticket;
    }
    
    public static void fireEvent(HasTicketSaveHandlers source, Ticket ticket) {
        source.fireEvent(new TicketSaveEvent(ticket));
    }

    @Override
    public com.google.gwt.event.shared.GwtEvent.Type<Handler> getAssociatedType() {
        return TYPE;
    }

    @Override
    protected void dispatch(Handler handler) {
        handler.onTicketSave(this);
    }    
}
